<script setup>
import itemData from '../data/ItemData.json'
import { getText } from '../store/txtstore.js'
const props = defineProps(['itemId', 'num', 'corner'])
const item = itemData.data[props.itemId]
const name = getText(item[2][1])
</script>

<template>
    <abbr :title="name">
        <figure :class="'rank-'+item[7]">
            <img :src="`/exilium/icons/item/${item[6]}.png`" :alt="name" class="icon">
            <img v-if="corner" :src="corner" class="corner">
            <figcaption>{{ num }}</figcaption>
        </figure>
    </abbr>
</template>

<style scoped>
figure {
    align-items: center;
    border: 1px solid lightgray;
    border-radius: 3px;
    box-sizing: border-box;
    display: inline-flex;
    height: 70px;
    justify-content: center;
    margin: 4px;
    position: relative;
    width: 70px;
}

img.icon {
    width: 64px;
}

.rank-2 img.icon {
    background: linear-gradient(to top, #3f995b, lightgray);
}

.rank-5 img.icon {
    background: linear-gradient(to top, #df9e00, lightgray);
}

img.corner {
    position: absolute;
    right: -4px;
    top: -4px;
    width: 24px;
}

figcaption {
    background-color: rgba(0,0,0,.5);
    border-bottom-style: solid;
    border-bottom-width: 3px;
    bottom: 2px;
    color: white;
    font-size: small;
    line-height: 1.2;
    position: absolute;
    text-align: center;
    width: 64px;
}

.rank-2 figcaption {
    border-bottom-color: #3f995b;
}

.rank-5 figcaption {
    border-bottom-color: #df9e00;
}
</style>